package zut.cs.liziflower.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import zut.cs.liziflower.entity.Address;
import zut.cs.liziflower.mapper.AddressMapper;
import zut.cs.liziflower.service.IAddressService;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author xuwenke
 * @since 2022-05-25
 */
@Service
public class AddressServiceImpl extends ServiceImpl<AddressMapper, Address> implements IAddressService {

    @Resource
    private AddressMapper addressMapper;

    @Override
    public int addAddress(Integer userid, String receivephone, String receiceprovince, String receivecity, String receivedistrict, String receiveaddress) {
        int i = addressMapper.addAddress(userid, receivephone, receiceprovince, receivecity, receivedistrict, receiveaddress);

        return 0;

    }

    @Override
    public List<Address> getAllAddress(Integer userid) {
        QueryWrapper<Address> wrapper = new QueryWrapper<>();
        wrapper.eq("userid", userid);
        List<Address> list = addressMapper.selectList(wrapper);
        return list;
    }

    @Override
    public int deleteAddress(Integer addressid) {
        return addressMapper.deleteById(addressid);
    }
}
